package io.renren.modules.wmhistory.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.groupunnormal.entity.GroupunnormalEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.wmhistory.entity.WmhistoryEntity;
import io.renren.modules.wmhistory.service.WmhistoryService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-02-10 13:25:59
 */
@RestController
@RequestMapping("wmhistory/wmhistory")
public class WmhistoryController {
    @Autowired
    private WmhistoryService wmhistoryService;

    @GetMapping("getWmHistory")
    public List<WmhistoryEntity> getWmHistory(@RequestParam(value = "key",required = false) String wName, @RequestParam(value = "startTime",required = false) String startTime, @RequestParam(value = "endTime",required = false) String endTime){
        return wmhistoryService.getWmHistory(wName,startTime,endTime);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("wmhistory:wmhistory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = wmhistoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{wmno}")
    @RequiresPermissions("wmhistory:wmhistory:info")
    public R info(@PathVariable("wmno") Integer wmno){
		WmhistoryEntity wmhistory = wmhistoryService.getById(wmno);

        return R.ok().put("wmhistory", wmhistory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("wmhistory:wmhistory:save")
    public R save(@RequestBody WmhistoryEntity wmhistory){
		wmhistoryService.save(wmhistory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("wmhistory:wmhistory:update")
    public R update(@RequestBody WmhistoryEntity wmhistory){
		wmhistoryService.updateById(wmhistory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("wmhistory:wmhistory:delete")
    public R delete(@RequestBody Integer[] wmnos){
		wmhistoryService.removeByIds(Arrays.asList(wmnos));

        return R.ok();
    }

}
